//
//  NewsCell.m
//  News_lzz
//
//  Created by qianfeng01 on 15-6-14.
//  Copyright (c) 2015年 李忠. All rights reserved.
//

#import "NewsCell.h"
#import "UIImageView+WebCache.h"

@implementation NewsCell

- (void)awakeFromNib {
    // Initialization code
    self.model = [[Model alloc] init];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

- (NewsCell *)setCellWithModel:(Model *)model {
    
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:nil];
    self.titleLabel.text = model.title;
    self.longTitleLabel.text = model.long_title;
    self.commentLabel.text = [model.comment stringValue];
    return self;
}

- (NewsCell *)setPicsWithModel:(Model *)model {

    self.titleLabel2.text = model.title;
    self.commentLabel2.text = [model.comment stringValue];
    NSArray *listPics = model.pics[@"list"];
    CGRect frame = self.scrollView.frame;
    frame.size.width = kScreenSize.width;
    self.scrollView.frame = frame;
    CGFloat h = self.scrollView.frame.size.height;
    CGFloat space = 5;
    CGFloat w = (self.scrollView.frame.size.width-space*4)/3;
    for (NSInteger i=0; i<listPics.count; i++) {
        NSDictionary *dict = listPics[i];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(space+(space+w)*i, 0, w, h)];
        [imageView sd_setImageWithURL:[NSURL URLWithString:dict[@"pic"]] placeholderImage:nil];
        [self.scrollView addSubview:imageView];
    }
    self.scrollView.contentSize = CGSizeMake(listPics.count*w, h);
    NSLog(@"##%@",self.scrollView);
    return self;
}


@end
